<%@ page language="java" import="java.util.*,com.hs.core.cache.*,com.hs.wdss.model.*" pageEncoding="utf-8"%>
<%
	WdssDisinfo obj = (WdssDisinfo)request.getAttribute("obj");
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../include.jsp"%>  
<script src="<%=basePath %>app/javascripts/transform.js"></script>
<script src='<%=basePath%>dwr/interface/dataProhelper.js'></script>  
<script language="javascript" type="text/javascript">
function savedata()
{
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	if(wdssid == ""){
		alert("请先保存医案信息！");	
		return;
	}else {
		var username = document.getElementById("username").value; 
		var sex = document.getElementById("sex").value; 
		var userage = document.getElementById("userage").value; 
		var agerangge = document.getElementById("agerangge").value; 
		var useraddress = document.getElementById("useraddress").value; 
		var memo = document.getElementById("memo").value; 
		if(isNull(username)){
			alert("请输入姓名！");
			return; 
   		} 
	   	dataProhelper.addUserinfo(username,userage,useraddress,agerangge,memo,sex,wdssid,callback4addUser);
	}
}
function callback4addUser(message){ 
    var cellFunctions = [    
          function(item) {   
           	return item.username;
          }, 
          function(item) {  
           	return item.sex;
          },
          function(item) {  
           	return item.userage;
          }, 
          function(item) {  
           	return item.agerangge;
          }, 
          function(item) {  
           	return item.useraddress;
          }, 
          function(item) {  
           	return item.memo;
          },
          function(item) {  
           	return "<a href=javaScript:onclick=deluser('"+item.id+"');>删 除</a>";
          }
      ];    
     var index = message.indexOf("$");  
     var userid = message.substring(0,index); 
     var rowdata = message.substring(index+1); 
     var data = eval('('+rowdata+')');   
      DWRUtil.addRows("userlist", data, cellFunctions,{
          rowCreator:function(options) { //自定义 tr 的创建行为 
          var trobj = document.createElement("tr");   
          trobj.setAttribute("id","user_"+userid);  
          return trobj; 
     },cellCreator:function(options) {
	 var cell = document.createElement("td"); 
	 return cell;
	}, escapeHtml:false
	     });
	    document.getElementById("username").value=''; 
	 	document.getElementById("sex").value='0'; 
	 	document.getElementById("userage").value=''; 
	 	document.getElementById("useraddress").value=''; 
	 	document.getElementById("agerangge").value=''; 
	 	document.getElementById("memo").value=''; 
	 	//刷新左边菜单
	 	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	 	window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
	    alert('基本信息保存成功！');   
}

function deluser(id){
	if(confirm("确认要删除该基本信息吗？")){
	        dataProhelper.delUserinfo(id,callback4delUser);
    }
} 
function callback4delUser(data){   
	var tbody  = document.getElementById("userlist");// tbody 的id 
    var rowobj = document.getElementById("user_"+data);  
    tbody.removeChild(rowobj);
    //刷新左边菜单
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
}
function backlist()
{
	window.parent.window.location.href = "<%=basePath%>produce/dataprolist.do"
}
</script>
</head>
<body>
<div class="current">当前位置：数据加工 &gt; 就诊人员信息</div>
		 <div class="add_form">
	        <table border="0" cellspacing="0" cellpadding="0" class="news"> 
	        <caption>
	          就诊人员信息
	          </caption>
	          <tr>
	            <th width="15%">姓名</th>
	            <td width="35%"><input type="text" name="username" id="username" value="" style="width:97%"/>
	            <input name="disid" type="hidden" value=""/>
	            <input name="userid" type="hidden" value=""/></td>
	            <th width="15%">性别</th>
	            <td width="35%"><%out.print(DictCacheUtil.getInst().selectStrNodefault("sex","width:100%",null,"24",null)); %></td>
	           
	          </tr>
	          <tr>
	           <th width="15%">年龄</th>
	            <td width="35%"><input type="text" name="userage" id="userage" value="" style="width:97%"/></td>
	            <th width="15%">年龄段</th>
	            <td width="35%"><%out.print(DictCacheUtil.getInst().selectStrNodefault("agerangge","width:100%",null,"25",null)); %></td>
	          </tr>
	          <tr>
	            <th width="15%">地址</th>
	            <td colspan=3 ><input type="text" name="useraddress" id="useraddress" value="" style="width:99%"/></td>
	          </tr> 
	           <tr>
	            <th width="15%">备注</th>
	            <td colspan=3><input type="text" name="memo" id="memo" value="" style="width:99%"/>
	            </td> 
	          </tr>
	          <tr> 
	           <td colspan=4 align=center >
	           		<input  type="button" value=" 保 存 " onclick="savedata();" class="butt"/>
	           		<input  type="button" value=" 返 回 " onclick="backlist();" class="butt"/>
	           </td>
	          </tr>
	        </table> 
        </div>
    	<table border="0" cellspacing="0" cellpadding="0" style="width:100%" class="list">
        	<caption>就诊人员列表</caption>  
          <tr>  
            <th width="10%">姓名</th>
            <th width="10%">性别</th>
            <th width="10%">年龄</th>
            <th width="10%">年龄段</th>
            <th width="25%">地址</th>
            <th width="25%">备注</th> 
            <th width="10%">删除</th> 
          </tr>
          <tbody id=userlist>
           <%if(obj != null && !obj.getUserinfoset().isEmpty()){
                Set userset = obj.getUserinfoset();
                Iterator iter = userset.iterator();
          		while(iter.hasNext()){ 
          			WdssUserinfo userinfo = (WdssUserinfo)iter.next(); 
           %>
	           <tr id=user_<%=userinfo.getId() %>>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=userinfo.getUsername()%></td>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=DictCacheUtil.getInst().selectStr4Display(userinfo.getSex(),"24") %></td>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=StringUtilTool.NULL2Blank(userinfo.getUserage())%></td>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=DictCacheUtil.getInst().selectStr4Display(userinfo.getAgerangge(),"25") %></td>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=StringUtilTool.NULL2Blank(userinfo.getUseraddress())%></td>
 	           <td style="word-break:break-all;over-flow:hidden;"><%=StringUtilTool.NULL2Blank(userinfo.getMemo())%></td>
 	           <td><a href="javaScript:onclick=deluser('<%=userinfo.getId() %>')">删除</a></td>
	           </tr>
           <%}} %>
           </tbody>
        </table>
       
</body>
</html>


